From b6d371f307705b32e1ef5c63d7bf6440c8859789 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Mon, 20 Oct 2025 19:43:27 +0200 Subject: [PATCH] system-linux: handle RTM_DELLINK events for device state tracking Add RTM_DELLINK handling to properly track device lifecycle. When a device is deleted, update its state with flags=0 to mark it as not present. This improves synchronization compared to only relying on the hotplug handler. Signed-off-by: Felix Fietkau --- system-linux.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/system-linux.c b/system-linux.c index 6582535..ceeabe3 100644 --- a/system-linux.c +++ b/system-linux.c @@ -732,8 +732,9 @@ static int cb_rtnl_event(struct nl_msg *msg, void *arg) struct ifinfomsg *ifi = NLMSG_DATA(nh); struct nlattr *nla[__IFLA_MAX]; struct device *dev; + unsigned int flags; - if (nh->nlmsg_type != RTM_NEWLINK) + if (nh->nlmsg_type != RTM_NEWLINK && nh->nlmsg_type != RTM_DELLINK) return 0; nlmsg_parse(nh, sizeof(struct ifinfomsg), nla, __IFLA_MAX - 1, NULL); @@ -744,7 +745,8 @@ static int cb_rtnl_event(struct nl_msg *msg, void *arg) if (!dev) return 0; - system_device_update_state(dev, ifi->ifi_flags); + flags = (nh->nlmsg_type == RTM_DELLINK) ? 0 : ifi->ifi_flags; + system_device_update_state(dev, flags); return 0; } -- 2.30.2